#pragma once

#include "cocos2d.h"
#include "GameHero.h"

class GameLayer : public cocos2d::CCLayer
{
public:
	int width;
	int height;
	int tileWidth;
	int tileHeight;
	int score;
	int level;
	int time;

	CCLabelTTF *scoreLabel;
	CCLabelTTF *levelLabel;
	CCLabelTTF *timeLabel;

	CCPoint heroStartPos;
	CCArray *nullPoints;
	CCArray *tileArray;
	CCArray *enemyArray;

	GameHero *hero;
	CCSprite *bomb;
	CCSprite *bombEffect;
	CCSprite *key;
	bool isBomb;
	bool isKey;

public:
	virtual bool init();

	CCPoint convertToTilePos(CCPoint pos);
	
	void gameUpdate(float f);
	void checkHeroState();
	void checkGameState();
	void updateTime();
	void gameOver();
	void gameWin();

	void pubBombEffect();
	void putBomb();
	void bombDown(float f);

	void loadNextLevel(int level);

	CREATE_FUNC(GameLayer);
	//static GameLayer* create();

private:
	void initTile();
	void initHero();
	void initEnemy();
	void initBomb();
	void reInit();
	

};
